package org.laowenchao.dao;

import java.util.Date;
import java.util.List;

import javax.jdo.PersistenceManager;
import javax.jdo.Query;

import org.laowenchao.pojo.*;
import org.laowenchao.server.PMF;

public class MyGSMPositionDao {

	public List<MyGSMPosition> getTracksByDate(Date date)
	{
		System.out.println(date);
		PersistenceManager pm = PMF.get().getPersistenceManager();
		Query q = pm.newQuery(MyGSMPosition.class);
		
		try
		{
			q.setFilter("date>startParam && date<endParam");
			q.declareImports("import java.util.Date");
			q.declareParameters("Date startParam,Date endParam");
			q.setOrdering("date desc");
			return (List) q.execute(date,new Date(date.getTime()+24*60*60*1000));	
		}
		finally
		{ 
			q.closeAll();
		}
	
	}
	
	public static void main(String args[])
	{
		MyGSMPositionDao dao = new MyGSMPositionDao();
		dao.getTracksByDate(new Date());
		
	}
}
